const mongoose = require('mongoose')

mongoose.connect('mongodb://localhost:27017/test', { useUnifiedTopology: true })

const Schema = mongoose.Schema

const topicSchema = new Schema({
    nickname: {
        type: String,
        required: true
    },
    topicType: {
        type: String,
        required: true
    },
    lastReview: {
        type: String,
        default: null
    },
    createdTime: {
        type: Date,
        default: Date.now
    },
    lastModifiedTime: {
        type: Date,
        default: Date.now
    },
    title: {
        type: String,
        required: true
    },
    content: {
        type: String,
        required: true
    },
    viewCount: {
        type: Number,
        default: 1
    }
})

module.exports = mongoose.model('Topic', topicSchema)